﻿using System.Collections.Generic;
using System.Text;
using MavenThought.Commons.Extensions;

namespace TFS.Kanban.VS2010.Queries
{
    public class FilterGroup
    {
        private IList<FilterCondition> _filterConditions;

        public FilterGroup()
        {
            _filterConditions = new List<FilterCondition>();
        }

        public FilterGroup AddCondition(FilterCondition condition)
        {
            _filterConditions.Add(condition);
            return this;
        }

        public string GetFilterGroup()
        {
            var result = new StringBuilder();

            _filterConditions.ForEach(condition => result.Append(condition.GetFilterCondition()));

            if (result.Length > 0)
            {
                result.Insert(0, "( ");
                result.Append(" )");
            }

            return result.ToString();
        }
    }
}
